#include "AI.h"

extern map<string, int> number_map;
extern map<string, int>::iterator number_it;

bool NumTag(char* word, char* type)
{
	int n = 0;
	bool floatFlag = false;

	number_it = number_map.find(word);

	if(number_it != number_map.end())
	{
		strcpy_s(type, TYPE_LENGTH, "NUM_ALPHA");
		return true;
	}

	else
	{
		while(word[n] != NULL)
		{
			if(word[n] == '.' && !floatFlag)
			{
				floatFlag = true;
			}

			else if(word[n] < '0' || word[n] > '9')
			{
				return false;
			}

			n++;
		}

		if(floatFlag)
		{
			strcpy_s(type, TYPE_LENGTH, "FLOAT");
			return true;
		}

		else
		{
			switch(n)
			{
			case 1:
				strcpy_s(type, TYPE_LENGTH, "INT1");
				break;
			case 2:
				strcpy_s(type, TYPE_LENGTH, "INT2");
				break;
			case 3:
				strcpy_s(type, TYPE_LENGTH, "INT3");
				break;
			case 4:
				strcpy_s(type, TYPE_LENGTH, "INT4");
				break;
			default:
				strcpy_s(type, TYPE_LENGTH, "INT");
			}

			return true;
		}
	}
}